<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>端对端加密聊天工具</title>
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <link rel="stylesheet" href="static/css/style.css">
</head>
<body>
  <div class="app-container">
    <div class="app-header">
      <div class="logo-container">
        <div class="logo-icon">
          <i class="fas fa-lock"></i>
        </div>
        <div>
          <h1 class="app-title">端对端加密聊天</h1>
          <p class="app-subtitle">安全通信 · 隐私保护 · 实时日志</p>
        </div>
      </div>
      <div class="connection-status">
        <span class="status-indicator status-disconnected" id="status-indicator"></span>
        <span id="connection-status-text">未连接</span>
      </div>
    </div>
    
    <div class="app-body">
      <div class="sidebar">
        <div class="panel" style="flex: 1;">
          <div class="panel-header">
            <i class="fas fa-cog"></i>
            <span>聊天设置</span>
          </div>
          <div class="panel-body">
            <button class="btn-action w-100 mb-3" onclick="createRoom()">
              <i class="fas fa-plus-circle"></i> 创建新房间
            </button>
            
            <div class="mb-3">
              <label class="form-label">房间ID</label>
              <div class="input-group">
                <input type="text" id="room-id-display" class="input-field" readonly />
                <button class="btn-action" onclick="copyRoomId()">
                  <i class="fas fa-copy"></i>
                </button>
              </div>
            </div>
            
            <div class="mb-3">
              <label class="form-label">加入房间ID</label>
              <input type="text" id="join-room-id" class="input-field" placeholder="输入房间ID" />
            </div>
            
            <div class="mb-3">
              <label class="form-label">房间密码</label>
              <input type="password" id="room-password" class="input-field" placeholder="设置房间密码（可选）" />
            </div>
            <div class="mb-3">
              <div class="terms-content mb-2" style="font-size: 0.8rem; line-height: 1.4; max-height: 150px; overflow-y: auto; border: 1px solid #ddd; padding: 10px; background-color: #f8f9fa; border-radius: 4px;">
                <h6>免责协议</h6>
                <p><strong>1. 使用风险</strong><br>
                本工具按"现状"提供，不提供任何形式的保证。使用本工具的风险由您自行承担。</p>
                
                <p><strong>2. 服务可用性</strong><br>
                我们不保证服务将不间断或无错误运行，也不对服务中断或故障负责。</p>
                
                <p><strong>3. 数据安全</strong><br>
                虽然我们采用端对端加密技术，但无法保证数据传输的绝对安全，您应自行承担数据传输风险。</p>
                
                <p><strong>4. 隐私政策</strong><br>
                我们不会存储您的聊天内容，但会记录必要的连接日志用于服务维护。</p>
                
                <p><strong>5. 法律合规</strong><br>
                您有责任确保使用本工具时遵守当地法律法规，不得用于非法目的。</p>
                
                <p><strong>6. 责任限制</strong><br>
                在任何情况下，我们均不对因使用本工具而造成的任何直接、间接或附带损害负责。</p>
                
                <p><strong>7. 协议变更</strong><br>
                我们保留随时修改本协议的权利，修改后的协议将在更新后立即生效。</p>
              </div>
              <div class="form-check">
                <input class="form-check-input" type="checkbox" id="agree-terms" />
                <label class="form-check-label" for="agree-terms">我已阅读并同意免责协议</label>
              </div>
            </div>
            
            <button class="btn-action w-100" onclick="joinRoom()">
              <i class="fas fa-sign-in-alt"></i> 加入房间
            </button>
            
            <div class="mt-4">
              <label class="form-label">在线用户</label>
              <div class="user-list" id="user-list-container">
                <div class="empty-state">
                  <i class="fas fa-users-slash"></i>
                  <p>暂无在线用户</p>
                </div>
              </div>
            </div>
          </div>
        </div>
        
        <div class="panel">
          <div class="panel-header">
            <i class="fas fa-terminal"></i>
            <span>系统日志</span>
          </div>
          <div class="panel-body" style="padding: 0;">
            <div class="log-panel" id="log-panel">
              <div class="log-entry">
                <span class="log-timestamp">[系统]</span>
                <span class="log-info">欢迎使用端对端加密聊天工具</span>
              </div>
              <div class="log-entry">
                <span class="log-timestamp">[系统]</span>
                <span class="log-info">系统已初始化，等待连接...</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="main-content">
        <div class="panel" style="flex: 1;">
          <div class="panel-header">
            <i class="fas fa-comments"></i>
            <span>实时聊天</span>
            <span class="encryption-badge">端对端加密</span>
          </div>
          <div class="panel-body" style="padding: 0; display: flex; flex-direction: column;">
            <div class="chat-container">
              <div class="chat-messages" id="messages">
                <div class="empty-state">
                  <i class="fas fa-comment-slash"></i>
                  <p>您尚未加入任何聊天室</p>
                </div>
              </div>
              <div class="chat-input">
                <input type="text" id="message-input" class="message-input" placeholder="输入消息..." disabled />
                <button class="btn-action btn-send" onclick="sendMessage()" disabled>
                  <i class="fas fa-paper-plane"></i>
                </button>
              </div>
            </div>
          </div>
        </div>
        
        <div class="status-bar">
          <div>
            <span>状态: </span>
            <span id="message-status-text">未连接</span>
          </div>
          <div>
            <span id="message-count">0</span> 条消息 · 
            <span id="user-count">0</span> 位用户
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/uuid@8.3.2/dist/umd/uuidv4.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.2/socket.io.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jsencrypt/3.3.1/jsencrypt.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jsrsasign/10.8.2/jsrsasign-all-min.js"></script>
  <script src="static/js/main.js"></script>
</body>
</html>

